package com.party.core.model.counterfoil;

import com.google.common.collect.Maps;

import java.util.Map;

/**
 * OrderType
 * 活动订单状态
 *
 * @author Wesley
 * @data 16/9/18 9:22 .
 */
public enum CounterfoilType {
    TYPE_FREE(1, "免费"),

    TYPE_ON_LINE(2, "在线付费"),

    TYPE_OFF_LINE(3, "线下付费");

    //状态码
    private Integer code;

    //状态值
    private String value;

    CounterfoilType(Integer code, String value) {
        this.code = code;
        this.value = value;
    }

    /**
     * 根据状态码获取状态值
     *
     * @param code 状态码
     * @return 状态值
     */
    public static String getValue(Integer code) {
        for (CounterfoilType orderType : CounterfoilType.values()) {
            if (orderType.getCode().equals(code)) {
                return orderType.getValue();
            }
        }
        return null;
    }


    /**
     * 枚举类型转换为map
     *
     * @return 转换后的map
     */
    public static Map<Integer, String> convertMap() {
        Map<Integer, String> map = Maps.newHashMap();
        for (CounterfoilType orderType : CounterfoilType.values()) {
            map.put(orderType.getCode(), orderType.getValue());
        }
        return map;
    }


    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }
}
